
import 'package:flutter/material.dart';
import 'package:flutter_deer/account/iview/takeout_add_iview.dart';
import 'package:flutter_deer/account/models/user_score_takeout_entity.dart';
import 'package:flutter_deer/mvp/base_page_presenter.dart';
import 'package:flutter_deer/net/base_entity.dart';
import 'package:flutter_deer/net/dio_utils.dart';
import 'package:flutter_deer/net/http_api.dart';


class TakeoutAddPresenter extends BasePagePresenter<TakeoutAddIMvpView> {

  @override
  void initState() {
  }

  Future<dynamic> saveTakeout(String? bankId,String? cardNo,String? cardUsername,double? score) async {
    UserScoreTakeoutAddEntity addEntity = UserScoreTakeoutAddEntity(bankId: bankId,cardNo: cardNo,cardUsername: cardUsername,score: score);
    WidgetsBinding.instance.addPostFrameCallback((_) {
      requestNetwork<OperatorBaseEntity>(Method.post,
          url: HttpApi.saveTakeout,
          params: addEntity.toJson(),
          onSuccess: (data) {
            if(data!.data==true){
              view.saveTakeoutSuccess();
            }else{
              view.saveTakeoutFail();
            }
          },
        onError: (code,msg){

        }
      );
    });
  }

}